//
//  AttentTableViewCell.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/16.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "AttentTableViewCell.h"

@interface AttentTableViewCell()

@property (nonatomic, strong) UIButton *attentButton;
@property (nonatomic, strong) UIImageView *profileImageView;
@end


@implementation AttentTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier
                         type:(NSString *)type{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self loadSubviewsOnAttentCellWithType:type];
    }
    return self;
}


- (void)loadSubviewsOnAttentCellWithType:(NSString *)type{
    UIImageView *profileImageView = [[UIImageView alloc]init];
    profileImageView.image = [UIImage imageNamed:@"info_touxiang"];
    self.profileImageView = profileImageView;
    [self.contentView addSubview:profileImageView];
    [profileImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15*WIDTH);
        make.width.height.mas_equalTo(44*WIDTH);
    }];
    
    UILabel *nameLable = [[UILabel alloc]init];
    nameLable.text = @"白清";
    nameLable.textColor = KLColor_B6;
    nameLable.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16*WIDTH];
    [self.contentView addSubview:nameLable];
    [nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(profileImageView);
        make.left.equalTo(profileImageView.mas_right).offset(10*WIDTH);
    }];
    
    if ([type isEqualToString:@"attention"]) {   // 区别 两个类型
        UILabel *introduceLb = [[UILabel alloc]init];
        introduceLb.text = @"简介假案打卡机肯德基点卡服快递费接口爱打架";
        introduceLb.textColor = KLColor_B5;
        introduceLb.numberOfLines = 0;
        introduceLb.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
        [self.contentView addSubview:introduceLb];
        [introduceLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(profileImageView);
            make.left.equalTo(nameLable);
            make.width.mas_equalTo(291*WIDTH);
            make.height.mas_equalTo(18*HEIGHT);
        }];

    }else if ([type isEqualToString:@"fance"]){
        UILabel *introduceLb = [[UILabel alloc]init];
        introduceLb.text = @"简介假案打卡机肯德基点卡服快递费接口爱打架";
        introduceLb.textColor = KLColor_B5;
        introduceLb.numberOfLines = 0;
        introduceLb.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
        [self.contentView addSubview:introduceLb];
        [introduceLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(profileImageView);
            make.left.equalTo(nameLable);
            make.width.mas_equalTo(220*WIDTH);
            make.height.mas_equalTo(18*HEIGHT);
        }];
        
        UIButton *attentButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [attentButton setImage:[UIImage imageNamed:@"info_guanzhu_icon_jiahao"] forState:UIControlStateNormal];
        attentButton.backgroundColor = KLColor_A1;
        attentButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
        [attentButton setTitle:@"关注" forState:UIControlStateNormal];
        [attentButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [attentButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10*WIDTH)];
        [[attentButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
            
        }];
        self.attentButton = attentButton;
        [self.contentView addSubview:attentButton];
        [attentButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(-15*WIDTH);
            make.width.mas_equalTo(66*WIDTH);
            make.height.mas_equalTo(28*HEIGHT);
        }];
    }
    
    UIView *lineView = [[UIView alloc]init];
    lineView.backgroundColor = KLColor_B3;
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.right.equalTo(self.contentView);
        make.left.equalTo(profileImageView);
        make.height.mas_equalTo(1);
    }];
    
}


- (void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    [self.profileImageView layoutIfNeeded];
    [self.attentButton layoutIfNeeded];
    [self.profileImageView setRadiusWithValue:22*WIDTH];
    [self.attentButton setRadiusWithValue:14*HEIGHT];
}


- (void)setIsShow:(BOOL)isShow{
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
